import Link from "next/link"; import { type BillingInvoices, getBillingInvoices, getViewerSession } from "@/lib/popiart-api"; import { type Locale } from "@/lib/site-content"; export default async function BillingSuccessPage({ params, searchParams, }: { params: Promise<{ locale: string }>; searchParams: Promise<{ kind?: string; provider?: string; trade_no?: string }>; }) { const { locale } = await params; const { kind, provider, trade_no: tradeNo } = await searchParams; const typedLocale = locale as Locale; const isZh = typedLocale === "zh"; const session = await getViewerSession(); let invoices: BillingInvoices | null = null; if (session && tradeNo) { try { invoices = await getBillingInvoices({ keyword: tradeNo, page: 1, pageSize: 10 }); } catch { invoices = null; } } const matchedOrder = (invoices?.subscription_orders.items || []).find((item) => String(item.trade_no || "") === String(tradeNo || "")) || (invoices?.point_orders.items || []).find((item) => String(item.trade_no || "") === String(tradeNo || "")); return (
{isZh ? "PAYMENT" : "PAYMENT"}

{isZh ? "支付已完成" : "Payment completed"}

{isZh ? "订单状态已切换为成功。你可以继续回到控制台或账单中心查看最新订阅、积分和订单历史。" : "The order has completed successfully. Continue to the console or billing center to review the latest subscription, credits, and order history."}

{isZh ? "支付结果" : "Payment result"}

{isZh ? "订单类型" : "Order kind"} {kind || "-"}
{isZh ? "支付渠道" : "Provider"} {provider || "-"}
{isZh ? "交易号" : "Trade no"} {tradeNo || "-"}
{isZh ? "状态" : "Status"} {isZh ? "成功" : "Success"}
{matchedOrder ? ( <>
{isZh ? "订单标题" : "Order title"} {String(matchedOrder.plan_title || matchedOrder.package_name || "-")}
{isZh ? "金额" : "Amount"} {String(matchedOrder.money || "-")} {String(matchedOrder.currency || "")}
{isZh ? "支付方式" : "Payment method"} {String(matchedOrder.payment_method || "-")}
{isZh ? "完成时间" : "Completed at"} {String(matchedOrder.complete_time || "-")}
) : null}
{isZh ? "查看账单中心" : "Open billing"} {isZh ? "前往控制台" : "Open console"}
); }